package io.gitee.luoyuan800;

import ch.qos.logback.classic.Level;
import io.gitee.luoyuan800.tool.llm.agent.QwenAgent;
import io.gitee.luoyuan800.tool.llm.bean.config.AiAgentConfig;
import io.gitee.luoyuan800.tool.llm.bean.config.ModelConfig;
import io.gitee.luoyuan800.tool.llm.web.JavaHttpClient;
import io.gitee.luoyuan800.tool.llm.web.RestfulClient;
import org.slf4j.LoggerFactory;

import java.util.Map;

public class Main {
    public static void main(String[] args) {
        thinking(args[0], "请生成一个展示太阳系的 html 网页，八大行星围绕太阳缓慢转动，点击对应的行星要可以显示相应的信息。我需要一个完整的网页，所有的 html、css、js都在一个文件中");
    }

    private static void noThinking(String token, String requirement) {
        RestfulClient restfulClient = new JavaHttpClient();
        AiAgentConfig thinkingAiAgentConfig = new AiAgentConfig();
        ModelConfig modelConfig = new ModelConfig();
        modelConfig.setToken(token);
        modelConfig.setModel("qwen-plus-latest");
        thinkingAiAgentConfig.setModelConfig(modelConfig);
        thinkingAiAgentConfig.setWebSearch(false);
        thinkingAiAgentConfig.setEnableThink(false);
        thinkingAiAgentConfig.setStream(true);
        QwenAgent mainAgent = new QwenAgent(thinkingAiAgentConfig, restfulClient, "我负责干活");
        ((ch.qos.logback.classic.Logger) LoggerFactory.getILoggerFactory().getLogger("io.gitee.luoyuan800.tool.llm.agent.QwenAgent")).setLevel(Level.INFO);
        System.out.println(mainAgent.chat(requirement));
    }


    private static void thinking(String token, String requirement) {
        ThinkingAgentService thinkingAgentService = new ThinkingAgentService(token);
        Map<String, String> rs = thinkingAgentService.call(requirement);
        System.out.println("思考过程：");
        System.out.println(rs.get("thinking"));
        System.out.println("正式回答：");
        System.out.println(rs.get("result"));
    }
}